type pair = record
  a,b : int64;
end;

function mp(a,b : int64) : pair;
begin
  mp.a := a; mp.b := b;
end;

function get_aa(ii : integer) : pair;
var i : integer; ap,ac,t : pair;
begin
  ap := mp(1,0);
  ac := mp(0,1);
  for i := 3 to ii do
    begin
      t := ap;
      ap := ac;
      ac := mp(ac.a + t.a, ac.b + t.b);
    end;
  if ii = 1 then
    ac := ap;
  get_aa := ac;
end;

procedure swap(var a,b : int64);
var c : int64;
begin
  c := a; a := b; b := c;
end;

var ii,jj,k,ai,aj : int64;
    aai, aaj, aak : pair;
    dd,dx,dy : int64;
    d : array [0..1,0..2] of int64;

begin
  read(ii,jj,k,ai,aj);
  if ii > jj then
    begin swap(ii,jj); swap(ai,aj); end;
  aai := get_aa(ii);
  aaj := get_aa(jj);
  aak := get_aa(k);
  d[0,0] := aai.a; d[0,1] := aai.b; d[0,2] := ai;
  d[1,0] := aaj.a; d[1,1] := aaj.b; d[1,2] := aj; 
  dd := d[0,0]*d[1,1] - d[0,1]*d[1,0];
  dx := d[0,2]*d[1,1] - d[0,1]*d[1,2];
  dy := d[0,0]*d[1,2] - d[0,2]*d[1,0];
  writeln(dx div dd * aak.a + dy div dd * aak.b);
end.
